package logic

import (
	"context"
	"weixin/moble/mysql"

	"weixin/weixinrpc/internal/svc"
	"weixin/weixinrpc/weixinrpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type CircleLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewCircleLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CircleLogic {
	return &CircleLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *CircleLogic) Circle(in *weixinrpc.CircleRequest) (*weixinrpc.CircleResponse, error) {
	// todo: add your logic here and delete this line
	circle := mysql.Circle{
		Title:  in.Title,
		UserId: int(in.UserId),
	}
	mysql.DB.Debug().Create(&circle)
	return &weixinrpc.CircleResponse{
		Id: int64(circle.ID),
	}, nil
}
